package com.linchong.concurrency.chapter3;

import lombok.extern.slf4j.Slf4j;

/**
 * @Author:linchong
 * @CreateTime:2020-01-01 23:23
 * @Description:
 */
/*class信息，描述符public,变量修饰符private等放到方法区中
 * 引用的地址bytes放到方法区
 * 具体的数据放到堆
 * */
@Slf4j
public class CreateThread4 {
	//方法区
	private int i = 0;
	private byte[] bytes = new byte[1024];
	public static int counter = 0;

	/**
	 * jvm执行时创建一个main线程，开辟一个虚拟机栈
	 **/

	public static void main(String[] args) {
		Thread t1 = new Thread(null, new Runnable() {
			@Override
			public void run() {
				try {
					add(1);
				} catch (Error e) {
					log.info("counter:{}", counter);
				}
			}
		}, "test", 1 << 24);
		t1.start();
	}

	private static void add(int i) {
		++counter;
		add(i + 1);
	}
}
